﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Presentacion/RestaurantesMaster.master" AutoEventWireup="true" CodeBehind="API_restaurante_gestion_mesa.aspx.cs" Inherits="UricaoWeb.Presentacion.API_restaurante_gestion_mesa" %>

<asp:Content ID="Content4" ContentPlaceHolderID="ContenidoDelModulo2" runat="server">

    <h2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Agregar Mesa</h2>    

        <form id="form1" runat="server">
            <center>
                <asp:GridView ID="GridView1" runat="server" AllowPaging="True" AutoGenerateColumns="False" DataKeyNames="IdMesa" DataSourceID="gestionMesasGV" ForeColor="#333333" GridLines="None" Width="455px" CssClass="mGrid">
                    <AlternatingRowStyle BackColor="White" />
                    <Columns>
                        <asp:CommandField ShowSelectButton="True" />
                        <asp:BoundField DataField="IdMesa" HeaderText="ID Mesa" InsertVisible="False" ReadOnly="True" SortExpression="IdMesa" />
                        <asp:BoundField DataField="capacidadMesa" HeaderText="Capacidad" SortExpression="capacidadMesa" />
                        <asp:BoundField DataField="NombreRestaurante" HeaderText="Restaurante" SortExpression="NombreRestaurante" />
                    </Columns>
                    <EditRowStyle BackColor="#2461BF" />
                    <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
                    <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
                    <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
                    <RowStyle BackColor="#EFF3FB" />
                    <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
                    <SortedAscendingCellStyle BackColor="#F5F7FB" />
                    <SortedAscendingHeaderStyle BackColor="#6D95E1" />
                    <SortedDescendingCellStyle BackColor="#E9EBEF" />
                    <SortedDescendingHeaderStyle BackColor="#4870BE" />
                </asp:GridView>
                <asp:SqlDataSource ID="gestionMesasGV" runat="server" ConnectionString="<%$ ConnectionStrings:UricaoBD %>" DeleteCommand="DELETE FROM [Mesa] WHERE [IdMesa] = @IdMesa" InsertCommand="INSERT INTO [Mesa] ([capacidadMesa], [fkRestaurante]) VALUES (@capacidadMesa, @fkRestaurante)" SelectCommand="mesasYRestaurante" UpdateCommand="UPDATE [Mesa] SET [capacidadMesa] = @capacidadMesa, [fkRestaurante] = @fkRestaurante WHERE [IdMesa] = @IdMesa" OnSelecting="gestionMesasGV_Selecting" SelectCommandType="StoredProcedure">
                    <DeleteParameters>
                        <asp:Parameter Name="IdMesa" Type="Int32" />
                    </DeleteParameters>
                    <InsertParameters>
                        <asp:Parameter Name="capacidadMesa" Type="Int16" />
                        <asp:Parameter Name="fkRestaurante" Type="Int32" />
                    </InsertParameters>
                    <UpdateParameters>
                        <asp:Parameter Name="capacidadMesa" Type="Int16" />
                        <asp:Parameter Name="fkRestaurante" Type="Int32" />
                        <asp:Parameter Name="IdMesa" Type="Int32" />
                    </UpdateParameters>
                </asp:SqlDataSource>
                <asp:FormView ID="FormView1" runat="server" CellPadding="4" DataKeyNames="IdMesa" DataSourceID="GestionMesaForm" ForeColor="#333333" Width="472px" OnPageIndexChanging="FormView1_PageIndexChanging" OnItemDeleted="FormView1_ItemDeleted" OnItemInserted="FormView1_ItemInserted" OnItemUpdated="FormView1_ItemUpdated">
                    <EditItemTemplate>
                        IdMesa:
                        <asp:Label ID="IdMesaLabel1" runat="server" Text='<%# Eval("IdMesa") %>' />
                        <br />
                        capacidadMesa:
                        <asp:TextBox ID="capacidadMesaTextBox" runat="server" Text='<%# Bind("capacidadMesa") %>' />
                        <br />
                        fkRestaurante:
                        <asp:TextBox ID="fkRestauranteTextBox" runat="server" Text='<%# Bind("fkRestaurante") %>' />
                        <br />
                        <asp:LinkButton ID="UpdateButton" runat="server" CausesValidation="True" CommandName="Update" Text="Update" />
                        &nbsp;<asp:LinkButton ID="UpdateCancelButton" runat="server" CausesValidation="False" CommandName="Cancel" Text="Cancel" />
                    </EditItemTemplate>
                    <EditRowStyle BackColor="#7C6F57" />
                    <FooterStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
                    <HeaderStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
                    <InsertItemTemplate>
                        capacidadMesa:
                        <asp:TextBox ID="capacidadMesaTextBox" runat="server" Text='<%# Bind("capacidadMesa") %>' />
                        <br />
                        fkRestaurante:
                        <asp:TextBox ID="fkRestauranteTextBox" runat="server" Text='<%# Bind("fkRestaurante") %>' />
                        <br />
                        <asp:LinkButton ID="InsertButton" runat="server" CausesValidation="True" CommandName="Insert" Text="Insert" />
                        &nbsp;<asp:LinkButton ID="InsertCancelButton" runat="server" CausesValidation="False" CommandName="Cancel" Text="Cancel" />
                    </InsertItemTemplate>
                    <ItemTemplate>
                        IdMesa:
                        <asp:Label ID="IdMesaLabel" runat="server" Text='<%# Eval("IdMesa") %>' />
                        <br />
                        capacidadMesa:
                        <asp:Label ID="capacidadMesaLabel" runat="server" Text='<%# Bind("capacidadMesa") %>' />
                        <br />
                        fkRestaurante:
                        <asp:Label ID="fkRestauranteLabel" runat="server" Text='<%# Bind("fkRestaurante") %>' />
                        <br />
                
                        <asp:LinkButton ID="EditButton" runat="server" CausesValidation="False" CommandName="Edit" Text="Edit" />
                        &nbsp;<asp:LinkButton ID="DeleteButton" runat="server" CausesValidation="False" CommandName="Delete" Text="Delete" />
                        &nbsp;<asp:LinkButton ID="NewButton" runat="server" CausesValidation="False" CommandName="New" Text="New" />
                    </ItemTemplate>
                    <PagerStyle BackColor="#666666" ForeColor="White" HorizontalAlign="Center" />
                    <RowStyle BackColor="#E3EAEB" />
                </asp:FormView>
                <asp:SqlDataSource ID="GestionMesaForm" runat="server" 
                    ConnectionString="<%$ ConnectionStrings:UricaoBD %>" 
                    DeleteCommand="DELETE FROM [Mesa] WHERE [IdMesa] = @IdMesa" 
                    InsertCommand="INSERT INTO [Mesa] ([capacidadMesa], [fkRestaurante]) VALUES (@capacidadMesa, @fkRestaurante)" 
                    SelectCommand="SELECT * FROM [Mesa] WHERE [IdMesa] = @IdMesa" 
                    UpdateCommand="UPDATE [Mesa] SET [capacidadMesa] = @capacidadMesa, [fkRestaurante] = @fkRestaurante WHERE [IdMesa] = @IdMesa">


                    <SelectParameters>
                            <asp:ControlParameter  ControlID= "GridView1" Name="IdMesa" Type="Int32" PropertyName="SelectedValue"/>
                    </SelectParameters>

                    <DeleteParameters>
                        <asp:Parameter Name="IdMesa" Type="Int32" />
                    </DeleteParameters>
                    <InsertParameters>
                        <asp:Parameter Name="capacidadMesa" Type="Int16" />
                        <asp:Parameter Name="fkRestaurante" Type="Int32" />
                    </InsertParameters>
                    <UpdateParameters>
                        <asp:Parameter Name="capacidadMesa" Type="Int16" />
                        <asp:Parameter Name="fkRestaurante" Type="Int32" />
                        <asp:Parameter Name="IdMesa" Type="Int32" />
                    </UpdateParameters>
                </asp:SqlDataSource>
            </center>
        </form>

</asp:Content>
